import java.util.Scanner;
public class GuessNumber {
    public static void main(String[] args) {
        int answer = (int) (Math.random() * 100 + 1);
        int num = 7;
        while (num > 0) {
            System.out.println("请猜1个1-100之间的整数（含1和100)" + "你还有" + num + "次机会");
            Scanner scan = new Scanner(System.in);
            String again;
            do {
                int guess=scan.nextInt();
                if (guess>answer){
                    System.out.println("猜大了");
                }else if(guess<answer){
                    System.out.println("猜小了");
                }else {
                    System.out.println("恭喜你猜对了！");
                    break;
                }
                num=num-1;
            if (num<=0){
                System.out.println("机会用完了");
            }
            System.out.println("还玩吗？(y/n)");
            again=scan.next();
            } while
            (again.equalsIgnoreCase("y"));
        }
    }
}